<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /* 
            slice(start, end)
                start：默认值0，开始的索引
                end：默认值是arr.length，不包含尾部的。
        */
       
        /* 
            需求：将array1的内容从cc-ff给复制出来。
            const array1 = ['aa','bb','cc','dd','ee','ff'];
         */
         const array1 = ['aa','bb','cc','dd','ee','ff'];
         const resArray = array1.slice(2);
         console.log(resArray);
         console.log("===================");

        const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
        console.log(animals.slice(2));  //camel,duck,elephant
        //不包含尾部的
        console.log(animals.slice(2, 4)); //camel,duck  or  camel,duck,elephant
        console.log(animals.slice(1, 5));
        console.log(animals.slice(-2));
        //不包含尾部的
        console.log(animals.slice(2, -1));
        //相当于 (0,animals.length)
        console.log(animals.slice());

    </script>
</head>
<body>
    
</body>
</html>